from openai import OpenAI
client = OpenAI(
  api_key='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'
)

# response = client.chat.completions.create(
#   model="gpt-4-1106-preview",
#   seed=3,
#   # response_format={ "type": "json_object" },
#   messages=[
#     {"role": "system", "content": "你是一个诗人"},
#     {"role": "user", "content": "写一首诗，描写青海的景色"}
#   ]
# )
# print(response.choices[0].message.content)

# for chunk in client.completions.create(
#   model="gpt-3.5-turbo-instruct",
#   prompt="你是一个诗人，写一首诗，描写青海的景色",
#   # messages=[
#   #   {"role": "system", "content": "你是一个诗人"},
#   #   {"role": "user", "content": "写一首诗，描写青海的景色"}
#   # ],
#   max_tokens=7,
#   temperature=0,
#   stream=True
# ):
#   print(chunk.choices[0].text)


# from pathlib import Path
# import openai
#
# openai.api_key='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'
# speech_file_path = Path(__file__).parent / "speech2.mp3"
# response = openai.audio.speech.create(
#   model="tts-1-hd",
#   voice="alloy",
#   speed=2,
#   input="你好啊，我是康雷小宝贝，啊哈。我一天到晚话特别多，还死喜欢不耐烦"
# )
# response.stream_to_file(speech_file_path)

# from openai import OpenAI
# client = OpenAI()

# print(client.models.list())

response = client.images.generate(
  model="dall-e-3",
  prompt="生成一辆跑车，飞驰在泥泞的土地里，泥浆飞溅,有个人坐在赛车上",
  n=1,
  size="1024x1024"
)
print(response)